﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;

namespace DotNetNeural.Visualisation
{
    /// <summary>
    /// Interaction logic for HoneycombCellControl.xaml
    /// </summary>
    public partial class HoneycombCellControl : UserControl
    {
        public HoneycombCellControl()
        {
            InitializeComponent();

            Draw();
        }

        protected void Draw()
        {
            PointCollection collection = new PointCollection();
            collection.Add(new Point(0, 0.5));
            collection.Add(new Point(0.25, 0));
            collection.Add(new Point(0.75, 0));
            collection.Add(new Point(1, 0.5));
            collection.Add(new Point(0.75, 1));
            collection.Add(new Point(0.25, 1));

            Polygon polygon = new Polygon();
            polygon.Points = collection;
            polygon.Fill = Brushes.Gold;
            polygon.Stroke = Brushes.Black;
            polygon.StrokeThickness = .5;
            polygon.UseLayoutRounding = true;
            polygon.Tag = this;

            polygon.MouseEnter += new MouseEventHandler(polygon_MouseEnter);
            polygon.MouseLeave += new MouseEventHandler(polygon_MouseLeave);

            polygon.Stretch = Stretch.Fill;

            layoutRoot.Children.Add(polygon);
        }

        void polygon_MouseLeave(object sender, MouseEventArgs e)
        {
            Polygon p = (Polygon)sender;
            p.StrokeThickness = .5;
            p.Stroke = Brushes.Black;
        }

        void polygon_MouseEnter(object sender, MouseEventArgs e)
        {
            Polygon p = (Polygon)sender;
            p.StrokeThickness = 3;
            p.Stroke = Brushes.SkyBlue;
        }
    }
}
